home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 42 / Amiga Format AFCD42 (Issue 126, Aug 1999).iso / -serious- / hardware / blizkick / modules / fusionreserve.asm < prev    next >
Assembly Source File  |  1999-05-17  |  4KB  |  169 lines

  1. ; FILE: Source:modules/FusionReserve.ASM          REV: 9 --- Do same as RsrvCold
  2.  
  3. ;
  4. ; FusionReserve for BlizKick
  5. ; ~~~~~~~~~~~~~~~~~~~~~~~~~~
  6. ; This module substitutes RsrvCold tool of FUSION MAC Emulator (Copyright
  7. ; © 1997 Jim Drew & Microcode Solutions). It should also work with
  8. ; Mac1200 (Copyright © 1992-1996 Jim Drew & Utilities Unlimited
  9. ; International, Inc.).
  10. ;
  11. ; Written by Harry Sintonen.
  12. ; This source code is Public Domain.
  13. ;
  14. ;
  15.  
  16.     incdir    "include:"
  17.     include    "exec/execbase.i"
  18.     include    "blizkickmodule.i"    ; Some required...
  19.  
  20.     SECTION    PATCH,CODE
  21. _DUMMY_LABEL
  22.     BK_PTC
  23.  
  24. ; Code is run with following incoming parameters:
  25. ;
  26. ; a0=ptr to ROM start (buffer)    eg. $1DE087B8
  27. ; a1=ptr to ROM start (ROM)    eg. $00F80000 (do *not* access!)
  28. ; d0=ROM lenght in bytes    eg. $00080000
  29. ; a2=ptr to _FindResident routine (will search ROM buffer for resident tag):
  30. ;    CALL: jsr (a2)
  31. ;      IN: a0=ptr to ROM, d0=rom len, a1=ptr to resident name
  32. ;     OUT: d0=ptr to resident (buf) or NULL
  33. ; a3=ptr to _InstallModule routine (can be used to plant a "module"):
  34. ;    CALL: jsr (a3)
  35. ;      IN: a0=ptr to ROM, d0=rom len, a1=ptr to module, d6=dosbase
  36. ;     OUT: d0=success
  37. ; a4=ptr to _Printf routine (will dump some silly things (errormsg?) to stdout ;-)
  38. ;    CALL: jsr (a4)
  39. ;      IN: a0=FmtString, a1=Array (may be 0), d6=dosbase
  40. ;     OUT: -
  41. ; d6=dosbase, a6=execbase
  42. ;
  43. ; Code should return:
  44. ;
  45. ; d0=true if succeeded, false if failed.
  46. ; d1-d7/a0-a6 can be trashed. a7 *must* be preserved! ;-)
  47.  
  48. NEWSTART    EQU    $4000
  49.  
  50.     moveq    #0,d7
  51.     move.l    a0,a5
  52.     move.l    d0,d5
  53.  
  54.     lsr.l    #1+5,d0            ; d0=1st 1/32th of the rom (words)
  55.     move.w    #$41F8,d2        ; cmp preload
  56.     move.l    #$210843F8,d3        ; -""-
  57. .find    subq.l    #1,d0
  58.     beq.b    .done
  59.     move.l    (a0),d1
  60.     addq.l    #2,a0
  61.     cmp.w    d1,d2
  62.     beq.b    .lea_a0
  63.     cmp.l    d1,d3
  64.     bne.b    .find
  65. .lea_a0    addq.l    #2,a0
  66.     cmp.w    #$3000,(a0)        ; A1200 rom!
  67.     beq.b    .is
  68.     cmp.w    #$0400,(a0)
  69.     beq.b    .is
  70.     cmp.w    #$1000,(a0)
  71.     beq.b    .is
  72.     cmp.w    #$2000,(a0)
  73.     bne.b    .find
  74. .is    move.w    #NEWSTART,(a0)
  75. .skip    addq.l    #1,d7
  76.     bra.b    .find
  77.  
  78. .done    move.l    d7,d0
  79.     beq.b    .failed
  80.  
  81.     move.l    a5,a0
  82.     move.l    d5,d0
  83.     lea    (_FusionReserveVBR,pc),a1
  84.     jsr    (a3)
  85.     bra.b    .exitok
  86.  
  87. .failed    lea    (.errmsg,pc),a0
  88.     jsr    (a4)
  89.     moveq    #0,d0
  90. .exitok    rts
  91.  
  92. .errmsg    dc.b    'This ROM isn''t compatible with FusionReserve patch!',10,0
  93.     CNOP    0,2
  94.  
  95. _FusionReserveVBR
  96.  BK_MOD BKMF_SingleMode,_end,(RTF_COLDSTART)<<24+37<<16+NT_UNKNOWN<<8+104,_name,_idstr,_init
  97.  
  98. ; Singlemode on,
  99. ; COLDSTART module, requires KS V37.x or better, module type NT_UNKNOWN, priority 104.
  100.  
  101. _init    movem.l    d0-a6,-(sp)
  102.     move.l    (4).w,a6        ; Really need 010+ =)
  103.     btst    #AFB_68010,(AttnFlags+1,a6)
  104.     beq.b    .exit2
  105.     jsr    (-$78,a6)        ;call    Disable
  106.  
  107.     lea    (MemList,a6),a0        ; Is chipmem start moved?
  108.     lea    (.chipname,pc),a1
  109.     jsr    (-$114,a6)        ;call    FindName
  110.     cmp.l    #$200000,d0
  111.     blo.b    .in_chip
  112.     move.l    d0,a0            ; node in fastmem so get
  113.     move.l    (20,a0),d0        ; MH_LOWER and compare that.
  114. .in_chip    cmp.l    #NEWSTART,d0
  115.     blo.b    .exit            ; not moved, so quit!
  116.  
  117.     lea    (.getvbr,pc),a5
  118.     jsr    (-$1E,a6)        ;call Supervisor
  119.     tst.l    d0
  120.     bne.b    .doclear        ; was .exit ! Stupid me !-(
  121.  
  122.     move.l    #$400,d0
  123.     moveq    #1,d1            ;MEMF_PUBLIC,d1
  124.     jsr    (-$2AC,a6)        ;call    AllocVec
  125.     move.l    d0,d2
  126.     beq.b    .exit
  127.  
  128.     sub.l    a0,a0
  129.     move.l    d2,a1
  130.     move.l    #$400,d0
  131.     jsr    (-$276,a6)        ;call    CopyMemQuick
  132.     jsr    (-$27C,a6)        ;call    CacheClearU
  133.  
  134.     lea    (.setvbr,pc),a5
  135.     jsr    (-$1E,a6)        ;call Supervisor
  136.  
  137. .doclear
  138. ;    lea    ($100).w,a0
  139. ;    move.w    #(NEWSTART-$100)/8-1,d0
  140. ;.clear    clr.l    (a0)+
  141. ;    clr.l    (a0)+
  142. ;    dbf    d0,.clear
  143.  
  144.     clr.b    ($3E85).w
  145.     clr.b    ($3E48).w
  146.     move.l    #'RSRV',($2118).w
  147.  
  148.     jsr    (-$27C,a6)        ;call    CacheClearU
  149. .exit    jsr    (-$7E,a6)        ;call    Enable
  150. .exit2    movem.l    (sp)+,d0-a6
  151.     rts
  152.  
  153. .getvbr    movec    vbr,d0
  154.     rte
  155. .setvbr    movec    d2,vbr
  156.     rte
  157.  
  158. .chipname    dc.b    'chip memory',0
  159. _name
  160. _idstr    dc.b    'FusionReserveVBR',0
  161.     CNOP    0,2
  162. _end
  163.  
  164.  
  165.     SECTION    VERSION,DATA
  166.  
  167.     dc.b    '$VER: FusionReserve_PATCH 1.2 (25.11.97)',0
  168.  
  169.